package com.tencent.bk.sdk.iam.util;

import com.tencent.bk.sdk.iam.dto.response.ResponseDTO;
import com.tencent.bk.sdk.iam.exception.IamException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResponseUtil {
    private static final Logger log = LoggerFactory.getLogger(ResponseUtil.class);

    public ResponseUtil() {
    }

    public static <T> void checkResponse(ResponseDTO<T> responseInfo) {
        // log.debug("Receive response|{}|{}|{}", new Object[]{responseInfo.getCode(), responseInfo.getMessage(), responseInfo.getData()});
        if (responseInfo.getCode() != 0L) {
            // log.error("Error while checking iam response!|{}|{}", responseInfo.getCode(), responseInfo.getMessage());
            throw new IamException(responseInfo.getCode(), responseInfo.getMessage());
        }
    }
}
